www.gusucode.com > VC++ 实现绘制椭圆、画矩形-源码程序 > VC++ 实现绘制椭圆、画矩形-源码程序/code/MenuTestView.cpp

    // MenuTestView.cpp : implementation of the CMenuTestView class
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "MenuTest.h"

#include "MenuTestDoc.h"
#include "MenuTestView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMenuTestView

IMPLEMENT_DYNCREATE(CMenuTestView, CView)

BEGIN_MESSAGE_MAP(CMenuTestView, CView)
	//{{AFX_MSG_MAP(CMenuTestView)
	ON_COMMAND(ID_DRAW_RECT, OnDrawRect)
	ON_COMMAND(ID_DRAW_CIRCLE, OnDrawCircle)
	ON_COMMAND(ID_DRAW_DISABLE, OnDrawDisable)
	ON_COMMAND(ID_DRAW_ENABLE, OnDrawEnable)
	ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect)
	ON_UPDATE_COMMAND_UI(ID_DRAW_ENABLE, OnUpdateDrawEnable)
	ON_UPDATE_COMMAND_UI(ID_DRAW_DISABLE, OnUpdateDrawDisable)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMenuTestView construction/destruction

CMenuTestView::CMenuTestView()
{
	// TODO: add construction code here
	m_Enable = TRUE;

}

CMenuTestView::~CMenuTestView()
{
}

BOOL CMenuTestView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMenuTestView drawing

void CMenuTestView::OnDraw(CDC* pDC)
{
	CMenuTestDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMenuTestView printing

BOOL CMenuTestView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMenuTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMenuTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMenuTestView diagnostics

#ifdef _DEBUG
void CMenuTestView::AssertValid() const
{
	CView::AssertValid();
}

void CMenuTestView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMenuTestDoc* CMenuTestView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMenuTestDoc)));
	return (CMenuTestDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMenuTestView message handlers

void CMenuTestView::OnDrawRect() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.Rectangle(50,50,200,150);      
	
}

void CMenuTestView::OnDrawCircle() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.Ellipse(250,50,400,150);      
	
}

void CMenuTestView::OnDrawDisable() 
{
	// TODO: Add your command handler code here
	m_Enable = FALSE;		
	
}

void CMenuTestView::OnDrawEnable() 
{
	// TODO: Add your command handler code here
	m_Enable = TRUE;		
	
}

void CMenuTestView::OnUpdateDrawRect(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(m_Enable);	
}

void CMenuTestView::OnUpdateDrawEnable(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_Enable ? 1:0);	
}

void CMenuTestView::OnUpdateDrawDisable(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_Enable ? 0:1);	
}